﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ToWaDBFirst.Models;

namespace ToWaDBFirst.Controllers
{
    /**
     * Controller for the archive portion of the community. Includes homepage and details methods for checking and searching
     * on posts.
     **/
    [Authorize]
    public class ArchiveController : Controller
    {

        /**
         * Class objects to be used for database and service operations.
         **/
        ToWaDBFirstDBEntities2 db = new ToWaDBFirstDBEntities2();
        ToWaService service = new ToWaService();


        public ActionResult Index()
        {
            return View(new List<message>());
        }
        /**
         * Method to display the index of the archive.
         **/
        // GET: /Archive/
        [HttpPost]
        public ActionResult Index(string fromDate, string toDate, string fromWho)
        {
            return View(service.FindMessage(fromDate, toDate, fromWho, User.Identity.Name));
        }

        /**
         * Method to display details for the clicked message.
         **/
        // GET: /Archive/Details/5
        public ActionResult Details(int id)
        {
            MessageWrapper mw = service.InspectMessage(id);
            return View(mw);
        }
    }
}
